﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class Admin_Paper : System.Web.UI.Page
{
    protected void LogoutButton_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        FormsAuthentication.SignOut();
        Response.Redirect("~/Default.aspx");
    }
    protected void Page_Load(object sender, System.EventArgs e)
    {
    }
    protected void PaperFormView_ItemDeleted(object sender, FormViewDeletedEventArgs e)
    {
        PaperFormView.DataBind();
    }
    protected void PaperFormView_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName.ToUpper() == "CANCEL")
            PaperFormView.ChangeMode(FormViewMode.Insert);
    }
    protected void PaperGridView_SelectedIndexChanged(object sender, EventArgs e)
    {
        PaperFormView.PageIndex = (PaperGridView.PageSize * PaperGridView.PageIndex) + PaperGridView.SelectedIndex;
        PaperFormView.ChangeMode(FormViewMode.Edit);
        PaperGridView.DataBind();
        PaperGridView.SelectedIndex = -1;
    }
    protected void ClearImageButton_Click(object sender, ImageClickEventArgs e)
    {
        PaperTitleTextBox.Text = string.Empty;
        PaperFormView.ChangeMode(FormViewMode.Insert);
        ClearImageButton.OnClientClick = "return false;";
    }
    protected void SearchImageButton_Click(object sender, ImageClickEventArgs e)
    {
        PaperGridView.PageSize = (PageSizeDropDownList.SelectedIndex == -1 || PageSizeDropDownList.SelectedValue == "0" ? 5 : Convert.ToInt32(PageSizeDropDownList.SelectedValue));
        if (PaperTitleTextBox.Text != string.Empty)
        {
            PaperFormView.ChangeMode(FormViewMode.Insert);
            ClearImageButton.OnClientClick = string.Empty;
        }
        else
            ClearImageButton_Click(sender, e);
    }
    protected void NewImageButton_Click(object sender, ImageClickEventArgs e)
    {
        PaperFormView.ChangeMode(FormViewMode.Insert);
        PaperFormView.DataBind();
    }
    protected void PaperEntityDataSource_Command(object sender, EntityDataSourceChangedEventArgs e)
    {
        PaperGridView.DataBind();
        PaperFormView.ChangeMode(FormViewMode.Insert);
    }
}